package org.higginsexamples.tests.hbxclient;

import java.util.Properties;

import junit.framework.TestCase;

import org.eclipse.higgins.rp.icard.token.identity.DigitalIdentity;

public class HBXClientTest extends TestCase {

	/**
	 * Keystore used is same as used in RCP Identity Selector.
	 * 
	 * TODO why?
	 */
	public static final String ABSOLUTE_PATH = "/data/p/Higgins/dev/wsp-higgins/org.higginsexamples.tests";

	public static final String KEYSTORE_FILENAME = ABSOLUTE_PATH
			+ "/localhost.jks";
	public static final String KEY_ALIAS = "leaf";
	public static final String KEY_PASS = "changeit";

	/**
	 * Where the RCP identity selector will be running
	 */
	public static final String HOSTNAME = "localhost";
	public static final int PORT = 8088;

	public void testHBXClient() throws Exception {
		Properties props = getRequestProperties();
		HBXClient client = new HBXClient(KEYSTORE_FILENAME, KEY_ALIAS, KEY_PASS);
		DigitalIdentity di = client.callSelectorAndGetToken(HOSTNAME, PORT,
				props);
		assertNotNull(di);
	}

	private Properties getRequestProperties() {
		Properties p = new Properties();
		p.setProperty("tokenType", "urn:oasis:names:tc:SAML:1.0:assertion");
		p
				.setProperty(
						"requiredClaims",
						""
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier "
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"
								+ "");
		p
				.setProperty(
						"optionalClaims",
						""
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname "
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname "
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/streetaddress "
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/locality "
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/stateorprovince "
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/postalcode "
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/country "
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/homephone "
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/otherphone "
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/mobilephone "
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/dateofbirth "
								+ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/gender"
								+ "");
		return p;
	}
}
